Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: create ProvideCanonicalUrl component #2572

Merged
merged 11 commits into from
Feb 12, 2025

Conversation

rwd
Copy link
Contributor

@rwd rwd commented Feb 11, 2025

To replace canonicalUrl mixin.

The component generates four variants of the current page's canonical URL and provides them for injection to the default slot.

Examples:

  • canonicalUrl.withBothLocaleAndQuery: https://www.example.org/en/about-us?this=that
  • canonicalUrl.withOnlyQuery: https://www.example.org/about-us?this=that
  • canonicalUrl.withOnlyLocale: https://www.example.org/en/about-us
  • canonicalUrl.withNeitherLocaleNorQuery: https://www.example.org/about-us

The component is used by each layout and wraps around the component so that all descendants within the body of the page have access to the canonical URL if they inject it.

It also takes responsibility for providing link[hreflang="x-default"][rel="alternate"] and meta[property="og-url"] elements to the document head.

NOTE: This would ideally be a composable, but couldn't get that working wrt provision of baseUrl, i18n and route from Options API setup function where there is no vue/nuxt context available, and lack of v3 helpers like useContext.

Copy link

Preview deployment: https://pr-2572.portal-js.dev.eanadev.org/

@LeoniePeters LeoniePeters merged commit 245b695 into master Feb 12, 2025
18 checks passed
@LeoniePeters LeoniePeters deleted the refactor/ProvideCanonicalUrl-component branch February 12, 2025 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants